#!/bin/sh

mysqldiff

cleannsupdate <<!
server $nameserver $port
zone test.dyndns
update add delegate1.test.dyndns 3600 NS ns1.delegate1.test.dyndns
update add delegate1.test.dyndns 3600 NS ns2.delegate1.test.dyndns
update add ns1.delegate1.test.dyndns 3600 A 127.0.0.1
update add ns2.delegate1.test.dyndns 3600 A 127.0.0.1
send
answer
!

mysqldiff 1 'Check delegate1 added correctly'

cleannsupdate <<!
server $nameserver $port
zone test.dyndns
update add ns1.delegate2.test.dyndns 3600 A 127.0.0.1
update add ns2.delegate2.test.dyndns 3600 A 127.0.0.1
update add delegate2.test.dyndns 3600 NS ns1.delegate2.test.dyndns
update add delegate2.test.dyndns 3600 NS ns2.example.com
send
answer
!

mysqldiff 2 'Check delegate2 added correctly'

cleannsupdate <<!
server $nameserver $port
zone test.dyndns
update delete delegate2.test.dyndns NS
update delete delegate1.test.dyndns NS
send
answer
!

mysqldiff 3 'check delegate delete'

cleannsupdate <<!
server $nameserver $port
zone test.dyndns
update delete ns1.delegate2.test.dyndns A
update delete ns2.delegate2.test.dyndns A
update delete ns1.delegate1.test.dyndns A
update delete ns2.delegate1.test.dyndns A
send
answer
!

mysqldiff 4 'Check if glue records are deleted and zone back to how we started'
